#!/bin/tcsh -ef
#############################################################################
#                                                                           #
# Title: Modify Image Parameters                                            #
#                                                                           #
# (C) 2dx.org, GNU Plublic License.                                         #
#                                                                           #
# Created..........: 03/01/2006                                             #
# Last Modification: 03/01/2006                                             #
# Author...........: 2dx.org                                                #
#                                                                           #
#############################################################################
#
# SORTORDER: 20
#
# MANUAL: This script will modify and refresh the 2dx_image.cfg files in the image directories. 
#
# MANUAL: In order to do so, it will read the config files in all selected image directories, change values, and save them again.
#
# 
# RESET: addPhaOri = "0.0,0.0"
# RESET: addPhaOriFouFilter = "0.0,0.0"
# RESET: addBeamTilt = "0.0,0.0"
#
#$end_local_vars
#
set proc_2dx = ""
set bin_2dx = ""
#
set addPhaOri = ""
set addPhaOriFouFilter = ""
set addBeamTilt = ""
#
#$end_vars
#
echo addPhaOri = ${addPhaOri}
echo addPhaOriFouFilter = ${addPhaOriFouFilter}
echo addBeamTilt = ${addBeamTilt}
#
set scriptname = 2dx_modifyImageParameter
\rm -f LOGS/${scriptname}.results
#
set ccp4_setup = 'y'
source ${proc_2dx}/initialize
#
echo "<<@progress: 1>>"
#
#############################################################################
${proc_2dx}/linblock "2dx_merge_modifyImageParameter.exe"
#############################################################################
#
set dirfile = "2dx_merge_dirfile.dat"
set olddir = `pwd`
cd ..
set base = `pwd`
cd ${olddir}
#
${proc_2dx}/linblock "base is ${base}"
#
if ( ! -e ${dirfile} ) then
  ${proc_2dx}/protest "ERROR: 2dx_merge did not provide the directory list."
endif
#
if ( -z ${dirfile} ) then
  ${proc_2dx}/linblock "ERROR: Directory list is empty."
  ${proc_2dx}/protest "ERROR: Did you select directories?"
endif
#
${bin_2dx}/2dx_merge_modifyImageParameter.exe << eot
LOGS/${scriptname}.results
${dirfile}
${base}
${addPhaOri}
${addPhaOriFouFilter}
${addBeamTilt}
eot
#
echo "<<@progress: 100>>"
#
${proc_2dx}/linblock "${scriptname} finished correctly."
#
